{template 'common/header'}

<link href="{MODULE_URL}template/web/css/classlist.css" rel="stylesheet" type="text/css">
<style type="text/css">.right-content{padding: 0;}
.sobox{
    width: 450px;
    height: 70px;
    margin: auto;
    position: relative;
    display: block;
}
.border-l:{
    border-left: #666 1px solid;
}
.border-r:{
    border-right: : #666 1px solid;
} 
.list_th{
    height: 30px;   
    line-height: 30px;

}
.list_tr{
    height: 100px;  
    line-height: 100px;
}
.J_add{
    margin-top:25px;
}
.goods-img{
    width: 80px;
    height:80px;
    margin: 10px;
    display: block;
}
.isok{
    background: #5CA209;
}
.isoff{
    background: #9c9c9c;
}
.gl{
    height: 20px !important;
}
.td span{
    display: block;
}
.info{
    width: 100%;
    height: 25px;
    text-align: center;
    line-height: 25px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.td .left_padding {
    padding-left: 10px !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ordertype{
    font-size: 14px;   
    border-radius: 2px;
    color: #FFFFFF;
    text-decoration: none;
    width: 60px;
    height: 25px;
    margin-left: auto;
    margin-right: auto;
    line-height: 25px;
}
.ordertype-pay{
    background: #ff5d38;
}
.ordertype-online{
    background: #666;
}
        .mii-top{
        height: 100px;
        width: 96%;
        background: #ff5d38;
        margin: 0px 2%;
        display: block;
        box-shadow: 0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4);
    }
    .mii-box{
        width: 98%;
        height: 100px;
        line-height: 100px;
        margin-right: 1%;
        margin-left: 1%;
        background-color: #fff; 
    }
    .soisok{
        width: 100px;
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;        
    }
    .soclass{
        width: 100px;   
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;        
    }
    .sokey{
        width: 300px;
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;
    }

    .submit{
        width: 100px;
        height: 35px;
        background-color: #ff5d38;
        color: #FFFFFF;
        border-radius: 2px;
        border:0;
        display: inline-block;
        padding: 8px 12px;
        box-sizing: border-box;
        box-shadow: 0 2px 2px 0 rgba(255,93,56, 0.14), 0 3px 1px -2px rgba(255,93,56, 0.2), 0 1px 5px 0 rgba(255,93,56, 0.12);    
        line-height: 0px;  
        outline: none;  
    }
    .submit:hover{
        box-shadow: 0 14px 26px -12px rgba(255,93,56, 0.42), 0 4px 23px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(255,93,56, 0.2);
    }

</style>
<div class="mii-box text-center">
    <div class="sobox">
        <input type="text"  name="sokey" class="sokey" placeholder="请输入查询值">        
        <button type="button" class="btn dropdown-toggle submit" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">查询条件 <span class="caret"></span></button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a id="soorderid" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'soorderid'));}&key=">订单ID</a></li>
          <li role="separator" class="divider"></li>              
          <li><a id="somemberid" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somemberid'));}&key=">会员ID</a></li>
          <li role="separator" class="divider"></li> 
          <li><a id="somembername" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somembername'));}&key=">会员名称</a></li>
         <li role="separator" class="divider"></li> 
          <li><a id="somembermobile" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'somembermobile'));}&key=">会员手机号</a></li>          
          <li role="separator" class="divider"></li> 
          <li><a id="sopaybook" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'sopaybook'));}">支付预约</a></li>
          <li role="separator" class="divider"></li> 
          <li><a id="sobook" data-href="{php echo $this->createWebUrl('soorder',array('so'=>'sobook'));}">免费预约</a></li>
        </ul>
    </div>
</div>
<!-- </div> -->
{if $order}
{loop $order $k $o}
    <div class="list_th">
        <div class="td" style=" width:20%;">
         <div class="left_padding"><b>订单编号:</b>{$o['orderid']}</div>
        </div>
        <div class="td text-center" style=" width:30%;"><b>创建时间:</b>{php echo date('Y-m-d H:i:s',$o['addtime'])} </div>
        <div class="td text-center" style=" width:30%;"><b>预约时段:</b>{php echo date('Y-m-d H:i',dejson($o['details'],'starttime'))}-{php echo date('H:i',dejson($o['details'],'endtime'))} </div>
        <div class="clear"></div>
    </div>
    <div class="list_tr link_bk">
            <div class="td text-center padding" style=" width:10%;">
            	<img class="goods-img" src="{$_W['attachurl']}{$o['titlepic']}">
                <div class="clear"></div>
            </div>
            <div class="td text-center border-r" style=" width:10%;line-height: 50px;" >
            	<span>项目名称</span>
            	<span class="info">{php echo dejson($o['details'],'goodsname')}</span> 
            </div>
            <div class="td text-center" style=" width:10%;line-height: 50px;" >
            	<span class="title">顾客姓名</span>
            	<span class="info">{php echo dejson($o['details'],'uname')}</span> 
            </div>            
            <div class="td text-center" style=" width:10%; line-height: 50px;" >    
            	<span>技师名称</span>
            	<span class="info">{php echo dejson($o['details'],'techname')}</span> 
            </div> 
            <div class="td text-center" style=" width:8%; line-height: 50px;" >
            	<span>预定类型</span>
                {if $o['order_type']=='2'}
            	<span class="ordertype ordertype-pay">支付预约</span> 
                {else if $o['order_type']=='1'}
                <span class="ordertype ordertype-online">免费预约</span>
                {else}
                <span class="ordertype ordertype-online">其他类型</span>
                {/if}     
            </div>
            <div class="td text-center" style=" width:10%; line-height: 50px;" >
                <span>在线支付</span>
                <span class="info">¥ {$o['pay_money']}</span>      
            </div>             
            <div class="td text-center" style=" width:10%; line-height: 50px;" >
                <span>到店需付</span>
                <span class="info">¥ {php echo $o['tmoney']-$o['pay_money']}</span>      
            </div>            
            <div class="td text-center" style=" width:10%;line-height: 50px;" >
            	<span>订单状态</span>
                {if $o['is_ok']=='0'}
            	<span class="info ordertype isoff">未完成</span>
                {else if $o['is_ok']}
                <span class="info ordertype isok">已完成</span>    
                {/if}
            </div>                                                  
            <div class="td edit text-center" style=" width:22%;">   
                <div class="list_right btn">
                    <a href="{php echo $this->createWebUrl('order_details',array('oid'=>$o['oid']));}">详情</a>
                    <a class="green isok" oid="{$o['oid']}" sid ="{$o['is_ok']}" >确认完成</a>
                    <a class="gray delete" did="{$o['oid']}" bid ="{$o['book_id']}">删除</a>                    
                </div>
            </div>
            <div class="clear"></div>
        </div>
 <div class="list_tr gl"></div> 
 {/loop}
 {else}
 {/if}  
{if $pager}       
<div class="list_tr">    
<div class="text-center">
  {php echo $pager;}
</div> 
</div>
{else}
{/if}
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script> 
<script type="text/javascript">
	$(document).ready(function(){
        //删除
        $(document).on('click','.delete', function () {
          if(!confirm("确定要删除该订单吗！删除不可恢复！")){                
               window.event.returnValue=false;
           }else{
               $.ajax({
                   url:"{php echo $this->createWebUrl('orderdel');}&version_id="+"{$_GPC['version_id']}",
                   data:{did:$(this).attr('did'),bid:$(this).attr('bid')},
                   dataType:"json",
                   type:"post",
                  success:function(res){
                     if(res.status== 1){
                         mqToast({type:1,context: res.msg}); 
                          setTimeout(function(){
                            window.location.reload();
                          },1000); 
                         return false;
                     }else{
                         mqToast({type:1,context: res.msg}); 
                         return false;
                     }
                  }
                })                    
           }        
        }); 

        //确认完成
        $(document).on('click','.isok',function(){
            var sid = $(this).attr('sid');
            var oid = $(this).attr('oid');
            if(sid !=1){
                if(!confirm('您确认已完成该订单吗？')){
                    window.event.returnValue = false;
                }else{
                    $.ajax({
                        url:"{php echo $this->createWebUrl('orderisok');}&version_id="+"{$_GPC['version_id']}",
                        data:{oid:oid,sid:sid},
                        dataType:"json",
                        type:"post",
                        success:function(res){
                            if(res.status==1){
                                mqToast({type:1,context: res.msg});
                                  setTimeout(function(){
                                    window.location.reload();
                                  },2000);
                            }else{
                                mqToast({type:1,context: res.msg});
                            }
                        }
                    })
                }
            }else{
                mqToast({type:1,context: '该订单已完成'});
            }
        })

	});
    //so
    // $(document).on('click','.sobt',function(){
    //     var sokey = $.trim($('.sokey').val());
    //     if(sokey==''){
    //         mqToast({type:1,context:'请输入搜索值'});
    //         return false;
    //     }else{
    //         var URL= "{php echo $this->createWebUrl('soorder');}"+"&sokey="+sokey;
    //         window.location.href = URL;
    //     }
    // })
    $('#soorderid').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的订单编号'});  
            return false
         }
         if(isNaN(key)){
            mqToast({type:1,context: '请输入纯数字'});
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somemberid').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员id'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })
    $('#somembername').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员名称'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })

    $('#somembermobile').on("click",function(){
         var toSearchPage = $(this).attr('data-href');
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的会员手机号'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })                
    $('#sopaybook').on("click",function(){
        var toSearchPage = $(this).attr('data-href');
        window.location.href = toSearchPage;
    })
    $('#sobook').on("click",function(){
        var toSearchPage = $(this).attr('data-href');
        window.location.href = toSearchPage;
    })        
</script>
{template 'common/footer'}